package com.result;

/**
 * Created by zxd on 2021/12/11 10:50
 */
public class ResultUtils {


    /**
     * 构建带分页结果集的成功
     * @param data
     * @param count
     * @return
     */
    public static Result buildSuccess(Object data,Long count){
        Result result=new Result();
        result.setCode(0);
        result.setData(data);
        result.setCount(count);
        return result;
    }

    /**
     * 构建数据结果成功
     * @param data
     * @return
     */
    public static Result buildSuccess(Object data){
        return buildSuccess(data,null);
    }

    /**
     * 构建不带数据的成功的结果集
     * @return
     */
    public static Result buildSuccess(){
      return buildSuccess(null,null);
    }


    /**
     * 构建失败的结果集
     * @return
     */
    public static Result buildFail(Integer code,String message){
        Result result=new Result();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

}
